package com.geek.zeus.demos.web.mq.consumer;

import com.geek.zeus.demos.web.mq.MQConstants;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.channels.Channel;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: geek
 * @Date: 2025/10/11/17:25
 * @Description:
 */
@Component
public class DirectReceiver {

    //直连模式的多个消费者，会分到其中一个消费者进行消费。类似task模式
    //通过注入RabbitContainerFactory对象，来设置一些属性，相当于task里的channel.basicQos
    @RabbitListener(queues= MQConstants.QUEUE_DIRECT,containerFactory="qos_4")
    public void directReceive22(Message message, Channel channel, String messageStr) {
        System.out.println("consumer1 received message : " +messageStr);
    }
}
